<template>
  <div class="content">
    <van-field v-model="password" placeholder="请输入密码" />
    <van-button @click="registerFn" :disabled="!flag" round block color="#ff6666" style="margin-top: 20px">注册</van-button>
  </div>
</template>
<script>
import Vue from 'vue'
import { Field, Button } from 'vant'
import { dofinishregister } from '@/api/user'
Vue.use(Field)
Vue.use(Button)
export default {
  data () {
    return {
      password: ''
    }
  },
  computed: {
    flag () {
      // /^\S*(?=\S{6,})(?=\S*\d)(?=\S*[A-Z])(?=\S*[a-z])(?=\S*[!@#$%^&*? ])\S*$/
      return this.password.length > 5
    }
  },
  methods: {
    registerFn () {
      dofinishregister({
        tel: localStorage.getItem('tel'),
        password: this.password
      }).then(res => {
        localStorage.removeItem('tel')
        this.$router.go(-3)
      })
    }
  }
}
</script>
